package com.sun.mvc.controller;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

// 注解配置SpringMVC的异常处理
@ControllerAdvice
public class ExceptionController {

    @ExceptionHandler(value = {ArithmeticException.class})
    public String handlerException(Exception exception, Model model){
        model.addAttribute("exception", exception);
        return "math_exception";
    }
}
